import { getMD5Sign, getMD5SignB } from '../util/util'


import axios from './axios'
import qs from "qs";

//初始化产品列表
export function productList(data) {
    data.sign = getMD5Sign(data)
    return axios(`/plus/zxs/points/productList`, {
        method: 'post',
        headers: data,
        // data:data
    })
}
// 下发短信
export function sendMessage(data, phone) {
    let a = data
    a.phone = phone
    data.sign = getMD5Sign(a)
    delete data.phone
    return axios(`/plus/zxs/points/limit/sendMessage`, {
        method: 'post',
        headers: data,
        data: {
            phone: phone
        }
    })
}
// 下单下发短信
export function sendMessageB(data) {
    data.sign = getMD5Sign(data)
    return axios(`/mall/points/orderVcode`, {
        method: 'post',
        headers: data,
        data: {
            bdProductCode: data.bdProductCode,
            quantity: data.quantity,
            reserved: data.reserved,
            userPhone: data.userPhone,
            thirdUserId:data.thirdUserId
        }
    })
}
// 验证短信并下单
export function payOrder(data) {
    data.sign = getMD5Sign(data)
    return axios(`/mall/points/orderPay`, {
        method: 'post',
        headers: data,
        data: {
            reserved: data.reserved,
            smsCode: data.smsCode,
            userPhone: data.userPhone,
            operDfp: data.operDfp
        }
    })
}
// 获取用户订单
export function userOrderList(data) {
    return axios(`/zxs/points/userOrderList?${params(data)}&sign=${getMD5Sign(data)}`, {
        method: 'get',
    })
}
// 获取用户ip
export function useripUrl() {
    return axios(`https://woread.diamond.clb.aizhishifm.cn/rest/internal/getIp`, {
        method: 'get',
    })
}
//积分查询1
export function scorecardPost(data) {
    data.sign = getMD5Sign(data)
    return axios(`/mall/points/loginCheck`, {
        method: 'post',
        headers: data,
        data: {
            smsCode: data.smsCode,
            userPhone: data.userPhone
        }
    })
}
//登陆验证码
export function scorecard201Post(data, phone) {
    data.sign = getMD5Sign(data)
    return axios(`/mall/points/loginVcode`, {
        method: 'post',
        headers: data,
        data: {
            userPhone: phone
        },
    })
}

//查询积分
export function PointsPost(data) {
    data.sign = getMD5Sign(data)
    return axios(`/mall/points/userQuery`, {
        method: 'post',
        headers: data,
        data: {
            userPhone: data.userPhone
        },
    })
}
//请求图片
export function imgTimePost(data) {
    data.sign = getMD5Sign(data)
    return axios("/mall/points/captcha ", {
        method: 'post',
        headers: data,
        data: {
            userPhone: data.userPhone
        },
    })
}
//请求滑块
export function huakuaiPost(data) {
    data.sign = getMD5Sign(data)
    return axios("/mall/points/captchaCheck", {
        method: 'post',
        headers: data,
        data: {
            userPhone: data.userPhone,
            uniqueKey:data.uniqueKey,
            pointInfo:data.pointInfo,
        },
    })
}
//获取openuid
export function openUid(data) {
    data.sign = getMD5Sign(data)
    console.log(data);
    return axios("/mall/points/tmUserId", {
        method: 'post',
        headers:data,
        data: {
            accessCode: data.accessCode,
            redirectUri:data.redirectUri,
        },
    })
}
//获取openuid
export function UserPhone(data) {
    // data.sign = getMD5Sign(data)
    return axios("/miaoguo/award/phoneDecrypt?userPhone="+data, {
        method: 'get',
        // headers:data,
        // data: {
        //     accessCode: data.accessCode,
        //     redirectUri:data.redirectUri,
        // },
    })
}
//发送验证码 
export function sendCode(dfp,exp,phone,uniqueKey,captchaVerification) {
    return axios(`/login/sms`, {
        method: 'post',
        headers:data,
        data: {
            dfp: dfp,
            exp:exp,
            phone:phone,
            uniqueKey:uniqueKey,
            captchaVerification:captchaVerification
        },
    })
}
// 登录
export function login(data) {
    // let query = ''
    // for (let key in current) {
    //     query += `${key}=${current[key]}&`
    // }
    // if (query) {
    //     query = '?' + query
    // }
    return axios(`/user/login`, {
        method: 'post',
        data:data
    })
}
// 查询积分 
export function queryPoints(data) {
    return axios(`/query/user`, {
        method: 'get',
        // headers: data
    })
}
// 匹配商品 
export function matchingProducts(data) {
    return axios(`/query/goods/detail?goods_sku_id=${data}`, {
        method: 'get',
    })
}

//1.执行
export function check() {
    console.log('dfp=', localStorage.getItem('dfp'));
    console.log('exp=', localStorage.getItem('exp'));
    return axios(`/check`, {
        method: 'post',
        headers: { "Content-Type": "application/json" },
        data:{
            dfp:localStorage.getItem('dfp'),
            exp:localStorage.getItem('exp')
         }
    })
}

// 支付验证码
export function payCode(data) {
    return axios(`/order/sms?orderId=${data}`, {
        method: 'get',
    })
}
// 创建顺丰订单
export function shunfengOrder(data) {
    return axios(`/order/shunfeng`, {
        method: 'post',
        data: data,
    })
}
// 创建飞猪订单
export function feizhuOrder(data) {
    return axios(`/order/feizhu`, {
        method: 'post',
        data: data,
    })
}
// 支付
export function payJFOrder(data) {
    return axios(`/play`, {
        method: 'post',
        data: data,
    })
}